﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Grpc.Core;
using GrpcLibrary;

namespace GrpcServer
{
    class GrpcImpl : GrpcService.GrpcServiceBase {
        public override Task<HelloReply> SayHello(HelloRequest request,ServerCallContext context)
        {
            return Task.FromResult(new HelloReply { Message = "haha Hello ====" + request.Name+"  "+request.Wtype,CmdType=100});
        }
    }



    class Program
    {
        const int _Port = 9007;

        static void Main(string[] args)
        {

            Server server = new Server()
            {
                Services = { GrpcService.BindService(new GrpcImpl()) },
                Ports = { new ServerPort("localhost", _Port, ServerCredentials.Insecure) }

            };


            server.Start();

            Console.WriteLine("GrpcService server listening on port " + _Port);
            Console.WriteLine("任意键退出...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();




        }
    }
}
